//
//  WorkManTipView.m
//  operativeSide
//
//  Created by 王春程 on 16/7/6.
//  Copyright © 2016年 com.caocaod.www. All rights reserved.
//

#import "WorkManTipView.h"
@interface WorkManTipView ()

@property (strong, nonatomic)               UIView *message;
@property (strong, nonatomic)               UILabel *tipLabel;
@property (strong, nonatomic)               UIButton *confirmBtn;
@property (strong, nonatomic)               UIButton *cancelBtn;

@end
@implementation WorkManTipView

- (instancetype)initWithFrame:(CGRect)frame {
    if(self = [super initWithFrame:frame]) {
        self.backgroundColor = RGBAlpha(0, 0, 0, 0.8);
        [self initSubView];
    }
    return self;
}

- (void)initSubView {
    _message = [[UIView alloc] initWithFrame:CGRectMake((VIEW_WIDTH - 250)/2, FrameHeight/2 - 48, 249, 93)];
    _message.layer.cornerRadius = 5;
    _message.layer.masksToBounds = YES;
    _message.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.message];
    
    
    _tipLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 17, 250, 20)];
    _tipLabel.text = @"确认接收";
    _tipLabel.textColor = RGB(51, 51, 51);
    _tipLabel.font = [UIFont systemFontOfSize:17];
    _tipLabel.textAlignment = NSTextAlignmentCenter;
    [self.message addSubview:self.tipLabel];
    
    _confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_confirmBtn.layer setBorderWidth:0.5];
    [_confirmBtn.layer setBorderColor:[UIColor grayColor].CGColor];
    _confirmBtn.frame = CGRectMake(0, 50, 250/2, 44);
    [_confirmBtn setTitle:@"确认" forState:UIControlStateNormal];
    [_confirmBtn setTitleColor:RGB(51, 51, 51) forState:UIControlStateNormal];
    _confirmBtn.titleLabel.font = [UIFont systemFontOfSize:12];
    [_confirmBtn addTarget:self action:@selector(confirmAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.message addSubview:self.confirmBtn];
    
    
    _cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_cancelBtn.layer setBorderWidth:0.5];
    [_cancelBtn.layer setBorderColor:[UIColor grayColor].CGColor];
    _cancelBtn.frame = CGRectMake(250/2 , 50, 250/2, 44);
    [_cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
    [_cancelBtn setTitleColor:RGB(51, 51, 51) forState:UIControlStateNormal];
    _cancelBtn.titleLabel.font = [UIFont systemFontOfSize:12];
    [_cancelBtn addTarget:self action:@selector(cancelAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.message addSubview:self.cancelBtn];
}

- (void)confirmAction:(UIButton *)sender {
    if([self.workManTipDelegate respondsToSelector:@selector(workManTipConfirmMessage)]) {
        [self.workManTipDelegate workManTipConfirmMessage];
    }
}

- (void)cancelAction:(UIButton *)sender {
    [self removeFromSuperview];
}

@end
